<?php
header('content-type:text/html;charset=utf-8');
session_start();
$usjh = $_SESSION['usjh'];
$psjh = $_POST['psjh'];
$money = $_POST['money'];
$din = "mysql:host=127.0.0.1;dbname=zgr";
$name = "root";
$password = "root";
$pdo = new PDO($din,$name,$password);
$pdo->beginTransaction();

$data1 = "update lx8_may set money = money - '$money' where sjh = '$usjh' ";
$data2 = "update lx8_may set money = money + '$money' where sjh = '$psjh' ";

$res1 = $pdo->exec($data1);
$res2 = $pdo->exec($data2);
if($res1>0 && $res2>0)
{
    echo "转账成功";
    $pdo->commit();
}
else
{
    echo "网络错误";
    $pdo->rollBack();
}
?>













